package cn.stylefeng.guns.controller.controller;

import cn.stylefeng.guns.modular.system.model.Web;
import cn.stylefeng.guns.modular.system.service.impl.WebServiceImpl;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.ui.Model;

import javax.servlet.http.HttpServletRequest;

@Controller
@RequestMapping(value = {"/","/DL"})
public class PsDlController {
        @Autowired
        WebServiceImpl webService;

        @RequestMapping(value = {"/{:^(?!static)\\b.+$}/**",""})
        public String PSDLUrl(HttpServletRequest request,Model model){
                EntityWrapper<Web> entityWrapper = new EntityWrapper<>();
                Wrapper<Web> one = entityWrapper.eq("url",request.getServletPath());
                Web web = webService.selectOne(one);
                model.addAttribute("content",web.getContent());
                return "/web/content.html";
        }
}
